const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
    mode: "development",
    devtool: "source-map",
    // 入口文件
    entry: './srcend/index.js',
    // 输出文件
    output: {
        filename: 'build/bundle.js',
        path: path.resolve(__dirname, 'distend')
    },
    // 配置loader
    module: {
        rules: [
            // style-loader和css-loader加载css文件
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader','postcss-loader']
            },
            {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', 'less-loader']
            },
            {
                test: /\.(png|jpe?g|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            name:'[folder]/[name]_[hash:6].[ext]',
                            limit: 100*1024
                        },
                    },
                ],
            },
        ]
    },
    plugins: [
        // new HtmlWebpackPlugin({
        //     template: "./src/index.html",
        //     allChunks: true
        // })
        new CleanWebpackPlugin(),
    ],
    // mode: "development"
    // mode: "production"


}
